import axios from 'axios';

axios.defaults.timeout = 500000;

//在开发环境中的测试 development
// if(process.env.NODE_ENV === 'development') {
// 	axios.defaults.baseURL = 'http://120.53.31.103:84/'
// }
//在生产环境中的测试 production
// if(process.env.NODE_ENV === 'production') {
// 	axios.defaults.baseURL = 'https://wap.365msmk.com/'
// }

/**
 * 封装get方法
 * @param url
 * @param params
 * @param head
 * @returns {Promise}
 */

export function get(url,params={},head){
  return new Promise((resolve,reject) => {
    axios.get(url,{
      params:params
    },
    head
    ).then(response => {
      resolve(response.data);
    })
    .catch(err => {
      reject(err)
    })
  })
}


/**
 * 封装post请求
 * @param url
 * @param data
 * @param head
 * @returns {Promise}
 */

export function post(url,data = {},head){
   return new Promise((resolve,reject) => {
    axios.post(url,data,
      head
      ).then(response => {
        resolve(response.data);
      },err => {
        reject(err)
      })
   })
 }
